3.1.60 \(\int (c+d \tan (e+f x))^2 (A+B \tan (e+f x)+C \tan ^2(e+f x)) \, dx\) [60]

3.1.60.1 Optimal result
3.1.60.2 Mathematica [C] (verified)
3.1.60.3 Rubi [A] (verified)
3.1.60.4 Maple [A] (verified)
3.1.60.5 Fricas [A] (verification not implemented)
3.1.60.6 Sympy [B] (verification not implemented)
3.1.60.7 Maxima [A] (verification not implemented)
3.1.60.8 Giac [B] (verification not implemented)
3.1.60.9 Mupad [B] (verification not implemented)

3.1.60.1 Optimal result

Integrand size = 33, antiderivative size = 131 \[ \int (c+d \tan (e+f x))^2 \left (A+B \tan (e+f x)+C \tan ^2(e+f x)\right ) \, dx=-\left (\left (c^2 C+2 B c d-C d^2-A \left (c^2-d^2\right )\right ) x\right )-\frac {\left (2 c (A-C) d+B \left (c^2-d^2\right )\right ) \log (\cos (e+f x))}{f}+\frac {d (B c+(A-C) d) \tan (e+f x)}{f}+\frac {B (c+d \tan (e+f x))^2}{2 f}+\frac {C (c+d \tan (e+f x))^3}{3 d f} \]

output
-(c^2*C+2*B*c*d-C*d^2-A*(c^2-d^2))*x-(2*c*(A-C)*d+B*(c^2-d^2))*ln(cos(f*x+ 
e))/f+d*(B*c+(A-C)*d)*tan(f*x+e)/f+1/2*B*(c+d*tan(f*x+e))^2/f+1/3*C*(c+d*t 
an(f*x+e))^3/d/f
 
3.1.60.2 Mathematica [C] (verified)

Result contains complex when optimal does not.

Time = 1.13 (sec) , antiderivative size = 176, normalized size of antiderivative = 1.34 \[ \int (c+d \tan (e+f x))^2 \left (A+B \tan (e+f x)+C \tan ^2(e+f x)\right ) \, dx=\frac {2 C (c+d \tan (e+f x))^3+3 (B c+(-A+C) d) \left (i \left ((c+i d)^2 \log (i-\tan (e+f x))-(c-i d)^2 \log (i+\tan (e+f x))\right )-2 d^2 \tan (e+f x)\right )+3 B \left ((i c-d)^3 \log (i-\tan (e+f x))-(i c+d)^3 \log (i+\tan (e+f x))+6 c d^2 \tan (e+f x)+d^3 \tan ^2(e+f x)\right )}{6 d f} \]

input
Integrate[(c + d*Tan[e + f*x])^2*(A + B*Tan[e + f*x] + C*Tan[e + f*x]^2),x 
]
 
output
(2*C*(c + d*Tan[e + f*x])^3 + 3*(B*c + (-A + C)*d)*(I*((c + I*d)^2*Log[I - 
 Tan[e + f*x]] - (c - I*d)^2*Log[I + Tan[e + f*x]]) - 2*d^2*Tan[e + f*x]) 
+ 3*B*((I*c - d)^3*Log[I - Tan[e + f*x]] - (I*c + d)^3*Log[I + Tan[e + f*x 
]] + 6*c*d^2*Tan[e + f*x] + d^3*Tan[e + f*x]^2))/(6*d*f)
 
3.1.60.3 Rubi [A] (verified)

Time = 0.59 (sec) , antiderivative size = 131, normalized size of antiderivative = 1.00, number of steps used = 8, number of rules used = 8, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.242, Rules used = {3042, 4113, 3042, 4011, 3042, 4008, 3042, 3956}

Below are the steps used by Rubi to obtain the solution. The rule number used for the transformation is given above next to the arrow. The rules definitions used are listed below.

\(\displaystyle \int (c+d \tan (e+f x))^2 \left (A+B \tan (e+f x)+C \tan ^2(e+f x)\right ) \, dx\)

\(\Big \downarrow \) 3042

\(\displaystyle \int (c+d \tan (e+f x))^2 \left (A+B \tan (e+f x)+C \tan (e+f x)^2\right )dx\)

\(\Big \downarrow \) 4113

\(\displaystyle \int (A-C+B \tan (e+f x)) (c+d \tan (e+f x))^2dx+\frac {C (c+d \tan (e+f x))^3}{3 d f}\)

\(\Big \downarrow \) 3042

\(\displaystyle \int (A-C+B \tan (e+f x)) (c+d \tan (e+f x))^2dx+\frac {C (c+d \tan (e+f x))^3}{3 d f}\)

\(\Big \downarrow \) 4011

\(\displaystyle \int (c+d \tan (e+f x)) (A c-C c-B d+(B c+(A-C) d) \tan (e+f x))dx+\frac {B (c+d \tan (e+f x))^2}{2 f}+\frac {C (c+d \tan (e+f x))^3}{3 d f}\)

\(\Big \downarrow \) 3042

\(\displaystyle \int (c+d \tan (e+f x)) (A c-C c-B d+(B c+(A-C) d) \tan (e+f x))dx+\frac {B (c+d \tan (e+f x))^2}{2 f}+\frac {C (c+d \tan (e+f x))^3}{3 d f}\)

\(\Big \downarrow \) 4008

\(\displaystyle \left (2 c d (A-C)+B \left (c^2-d^2\right )\right ) \int \tan (e+f x)dx-x \left (-A \left (c^2-d^2\right )+2 B c d+c^2 C-C d^2\right )+\frac {d \tan (e+f x) (d (A-C)+B c)}{f}+\frac {B (c+d \tan (e+f x))^2}{2 f}+\frac {C (c+d \tan (e+f x))^3}{3 d f}\)

\(\Big \downarrow \) 3042

\(\displaystyle \left (2 c d (A-C)+B \left (c^2-d^2\right )\right ) \int \tan (e+f x)dx-x \left (-A \left (c^2-d^2\right )+2 B c d+c^2 C-C d^2\right )+\frac {d \tan (e+f x) (d (A-C)+B c)}{f}+\frac {B (c+d \tan (e+f x))^2}{2 f}+\frac {C (c+d \tan (e+f x))^3}{3 d f}\)

\(\Big \downarrow \) 3956

\(\displaystyle -\frac {\left (2 c d (A-C)+B \left (c^2-d^2\right )\right ) \log (\cos (e+f x))}{f}-x \left (-A \left (c^2-d^2\right )+2 B c d+c^2 C-C d^2\right )+\frac {d \tan (e+f x) (d (A-C)+B c)}{f}+\frac {B (c+d \tan (e+f x))^2}{2 f}+\frac {C (c+d \tan (e+f x))^3}{3 d f}\)

input
Int[(c + d*Tan[e + f*x])^2*(A + B*Tan[e + f*x] + C*Tan[e + f*x]^2),x]
 
output
-((c^2*C + 2*B*c*d - C*d^2 - A*(c^2 - d^2))*x) - ((2*c*(A - C)*d + B*(c^2 
- d^2))*Log[Cos[e + f*x]])/f + (d*(B*c + (A - C)*d)*Tan[e + f*x])/f + (B*( 
c + d*Tan[e + f*x])^2)/(2*f) + (C*(c + d*Tan[e + f*x])^3)/(3*d*f)
 

3.1.60.3.1 Defintions of rubi rules used

rule 3042
Int[u_, x_Symbol] :> Int[DeactivateTrig[u, x], x] /; FunctionOfTrigOfLinear 
Q[u, x]
 

rule 3956
Int[tan[(c_.) + (d_.)*(x_)], x_Symbol] :> Simp[-Log[RemoveContent[Cos[c + d 
*x], x]]/d, x] /; FreeQ[{c, d}, x]
 

rule 4008
Int[((a_) + (b_.)*tan[(e_.) + (f_.)*(x_)])*((c_.) + (d_.)*tan[(e_.) + (f_.) 
*(x_)]), x_Symbol] :> Simp[(a*c - b*d)*x, x] + (Simp[b*d*(Tan[e + f*x]/f), 
x] + Simp[(b*c + a*d)   Int[Tan[e + f*x], x], x]) /; FreeQ[{a, b, c, d, e, 
f}, x] && NeQ[b*c - a*d, 0] && NeQ[b*c + a*d, 0]
 

rule 4011
Int[((a_.) + (b_.)*tan[(e_.) + (f_.)*(x_)])^(m_)*((c_.) + (d_.)*tan[(e_.) + 
 (f_.)*(x_)]), x_Symbol] :> Simp[d*((a + b*Tan[e + f*x])^m/(f*m)), x] + Int 
[(a + b*Tan[e + f*x])^(m - 1)*Simp[a*c - b*d + (b*c + a*d)*Tan[e + f*x], x] 
, x] /; FreeQ[{a, b, c, d, e, f}, x] && NeQ[b*c - a*d, 0] && NeQ[a^2 + b^2, 
 0] && GtQ[m, 0]
 

rule 4113
Int[((a_.) + (b_.)*tan[(e_.) + (f_.)*(x_)])^(m_.)*((A_.) + (B_.)*tan[(e_.) 
+ (f_.)*(x_)] + (C_.)*tan[(e_.) + (f_.)*(x_)]^2), x_Symbol] :> Simp[C*((a + 
 b*Tan[e + f*x])^(m + 1)/(b*f*(m + 1))), x] + Int[(a + b*Tan[e + f*x])^m*Si 
mp[A - C + B*Tan[e + f*x], x], x] /; FreeQ[{a, b, e, f, A, B, C, m}, x] && 
NeQ[A*b^2 - a*b*B + a^2*C, 0] &&  !LeQ[m, -1]
 
3.1.60.4 Maple [A] (verified)

Time = 0.08 (sec) , antiderivative size = 141, normalized size of antiderivative = 1.08

method result size
norman \(\left (A \,c^{2}-A \,d^{2}-2 B c d -c^{2} C +C \,d^{2}\right ) x +\frac {\left (A \,d^{2}+2 B c d +c^{2} C -C \,d^{2}\right ) \tan \left (f x +e \right )}{f}+\frac {C \,d^{2} \tan \left (f x +e \right )^{3}}{3 f}+\frac {d \left (B d +2 C c \right ) \tan \left (f x +e \right )^{2}}{2 f}+\frac {\left (2 A c d +B \,c^{2}-B \,d^{2}-2 C c d \right ) \ln \left (1+\tan \left (f x +e \right )^{2}\right )}{2 f}\) \(141\)
parts \(A \,c^{2} x +\frac {\left (2 A c d +B \,c^{2}\right ) \ln \left (1+\tan \left (f x +e \right )^{2}\right )}{2 f}+\frac {\left (B \,d^{2}+2 C c d \right ) \left (\frac {\tan \left (f x +e \right )^{2}}{2}-\frac {\ln \left (1+\tan \left (f x +e \right )^{2}\right )}{2}\right )}{f}+\frac {\left (A \,d^{2}+2 B c d +c^{2} C \right ) \left (\tan \left (f x +e \right )-\arctan \left (\tan \left (f x +e \right )\right )\right )}{f}+\frac {C \,d^{2} \left (\frac {\tan \left (f x +e \right )^{3}}{3}-\tan \left (f x +e \right )+\arctan \left (\tan \left (f x +e \right )\right )\right )}{f}\) \(144\)
derivativedivides \(\frac {\frac {C \,d^{2} \tan \left (f x +e \right )^{3}}{3}+\frac {B \,d^{2} \tan \left (f x +e \right )^{2}}{2}+C c d \tan \left (f x +e \right )^{2}+\tan \left (f x +e \right ) A \,d^{2}+2 \tan \left (f x +e \right ) B c d +\tan \left (f x +e \right ) c^{2} C -\tan \left (f x +e \right ) C \,d^{2}+\frac {\left (2 A c d +B \,c^{2}-B \,d^{2}-2 C c d \right ) \ln \left (1+\tan \left (f x +e \right )^{2}\right )}{2}+\left (A \,c^{2}-A \,d^{2}-2 B c d -c^{2} C +C \,d^{2}\right ) \arctan \left (\tan \left (f x +e \right )\right )}{f}\) \(162\)
default \(\frac {\frac {C \,d^{2} \tan \left (f x +e \right )^{3}}{3}+\frac {B \,d^{2} \tan \left (f x +e \right )^{2}}{2}+C c d \tan \left (f x +e \right )^{2}+\tan \left (f x +e \right ) A \,d^{2}+2 \tan \left (f x +e \right ) B c d +\tan \left (f x +e \right ) c^{2} C -\tan \left (f x +e \right ) C \,d^{2}+\frac {\left (2 A c d +B \,c^{2}-B \,d^{2}-2 C c d \right ) \ln \left (1+\tan \left (f x +e \right )^{2}\right )}{2}+\left (A \,c^{2}-A \,d^{2}-2 B c d -c^{2} C +C \,d^{2}\right ) \arctan \left (\tan \left (f x +e \right )\right )}{f}\) \(162\)
parallelrisch \(\frac {2 C \,d^{2} \tan \left (f x +e \right )^{3}+6 A \,c^{2} f x -6 A \,d^{2} f x -12 B c d f x +3 B \,d^{2} \tan \left (f x +e \right )^{2}-6 C \,c^{2} f x +6 C \,d^{2} f x +6 C c d \tan \left (f x +e \right )^{2}+6 A \ln \left (1+\tan \left (f x +e \right )^{2}\right ) c d +6 \tan \left (f x +e \right ) A \,d^{2}+3 B \ln \left (1+\tan \left (f x +e \right )^{2}\right ) c^{2}-3 B \ln \left (1+\tan \left (f x +e \right )^{2}\right ) d^{2}+12 \tan \left (f x +e \right ) B c d -6 C \ln \left (1+\tan \left (f x +e \right )^{2}\right ) c d +6 \tan \left (f x +e \right ) c^{2} C -6 \tan \left (f x +e \right ) C \,d^{2}}{6 f}\) \(200\)
risch \(-\frac {4 i C c d e}{f}+\frac {4 i A c d e}{f}+2 i A c d x -\frac {2 i B \,d^{2} e}{f}+A \,c^{2} x -A \,d^{2} x -2 B c d x -C \,c^{2} x +C \,d^{2} x +\frac {2 i \left (-6 i C c d \,{\mathrm e}^{2 i \left (f x +e \right )}-3 i B \,d^{2} {\mathrm e}^{4 i \left (f x +e \right )}+3 A \,d^{2} {\mathrm e}^{4 i \left (f x +e \right )}+6 B c d \,{\mathrm e}^{4 i \left (f x +e \right )}+3 C \,c^{2} {\mathrm e}^{4 i \left (f x +e \right )}-6 C \,d^{2} {\mathrm e}^{4 i \left (f x +e \right )}-6 i C c d \,{\mathrm e}^{4 i \left (f x +e \right )}-3 i B \,d^{2} {\mathrm e}^{2 i \left (f x +e \right )}+6 A \,d^{2} {\mathrm e}^{2 i \left (f x +e \right )}+12 B c d \,{\mathrm e}^{2 i \left (f x +e \right )}+6 C \,c^{2} {\mathrm e}^{2 i \left (f x +e \right )}-6 C \,d^{2} {\mathrm e}^{2 i \left (f x +e \right )}+3 A \,d^{2}+6 B c d +3 c^{2} C -4 C \,d^{2}\right )}{3 f \left ({\mathrm e}^{2 i \left (f x +e \right )}+1\right )^{3}}+\frac {2 i B \,c^{2} e}{f}+i B \,c^{2} x -i B \,d^{2} x -2 i C c d x -\frac {2 \ln \left ({\mathrm e}^{2 i \left (f x +e \right )}+1\right ) A c d}{f}-\frac {\ln \left ({\mathrm e}^{2 i \left (f x +e \right )}+1\right ) B \,c^{2}}{f}+\frac {\ln \left ({\mathrm e}^{2 i \left (f x +e \right )}+1\right ) B \,d^{2}}{f}+\frac {2 \ln \left ({\mathrm e}^{2 i \left (f x +e \right )}+1\right ) C c d}{f}\) \(410\)

input
int((c+d*tan(f*x+e))^2*(A+B*tan(f*x+e)+C*tan(f*x+e)^2),x,method=_RETURNVER 
BOSE)
 
output
(A*c^2-A*d^2-2*B*c*d-C*c^2+C*d^2)*x+(A*d^2+2*B*c*d+C*c^2-C*d^2)/f*tan(f*x+ 
e)+1/3*C*d^2/f*tan(f*x+e)^3+1/2*d*(B*d+2*C*c)/f*tan(f*x+e)^2+1/2*(2*A*c*d+ 
B*c^2-B*d^2-2*C*c*d)/f*ln(1+tan(f*x+e)^2)
 
3.1.60.5 Fricas [A] (verification not implemented)

Time = 0.27 (sec) , antiderivative size = 134, normalized size of antiderivative = 1.02 \[ \int (c+d \tan (e+f x))^2 \left (A+B \tan (e+f x)+C \tan ^2(e+f x)\right ) \, dx=\frac {2 \, C d^{2} \tan \left (f x + e\right )^{3} + 6 \, {\left ({\left (A - C\right )} c^{2} - 2 \, B c d - {\left (A - C\right )} d^{2}\right )} f x + 3 \, {\left (2 \, C c d + B d^{2}\right )} \tan \left (f x + e\right )^{2} - 3 \, {\left (B c^{2} + 2 \, {\left (A - C\right )} c d - B d^{2}\right )} \log \left (\frac {1}{\tan \left (f x + e\right )^{2} + 1}\right ) + 6 \, {\left (C c^{2} + 2 \, B c d + {\left (A - C\right )} d^{2}\right )} \tan \left (f x + e\right )}{6 \, f} \]

input
integrate((c+d*tan(f*x+e))^2*(A+B*tan(f*x+e)+C*tan(f*x+e)^2),x, algorithm= 
"fricas")
 
output
1/6*(2*C*d^2*tan(f*x + e)^3 + 6*((A - C)*c^2 - 2*B*c*d - (A - C)*d^2)*f*x 
+ 3*(2*C*c*d + B*d^2)*tan(f*x + e)^2 - 3*(B*c^2 + 2*(A - C)*c*d - B*d^2)*l 
og(1/(tan(f*x + e)^2 + 1)) + 6*(C*c^2 + 2*B*c*d + (A - C)*d^2)*tan(f*x + e 
))/f
 
3.1.60.6 Sympy [B] (verification not implemented)

Leaf count of result is larger than twice the leaf count of optimal. 241 vs. \(2 (107) = 214\).

Time = 0.13 (sec) , antiderivative size = 241, normalized size of antiderivative = 1.84 \[ \int (c+d \tan (e+f x))^2 \left (A+B \tan (e+f x)+C \tan ^2(e+f x)\right ) \, dx=\begin {cases} A c^{2} x + \frac {A c d \log {\left (\tan ^{2}{\left (e + f x \right )} + 1 \right )}}{f} - A d^{2} x + \frac {A d^{2} \tan {\left (e + f x \right )}}{f} + \frac {B c^{2} \log {\left (\tan ^{2}{\left (e + f x \right )} + 1 \right )}}{2 f} - 2 B c d x + \frac {2 B c d \tan {\left (e + f x \right )}}{f} - \frac {B d^{2} \log {\left (\tan ^{2}{\left (e + f x \right )} + 1 \right )}}{2 f} + \frac {B d^{2} \tan ^{2}{\left (e + f x \right )}}{2 f} - C c^{2} x + \frac {C c^{2} \tan {\left (e + f x \right )}}{f} - \frac {C c d \log {\left (\tan ^{2}{\left (e + f x \right )} + 1 \right )}}{f} + \frac {C c d \tan ^{2}{\left (e + f x \right )}}{f} + C d^{2} x + \frac {C d^{2} \tan ^{3}{\left (e + f x \right )}}{3 f} - \frac {C d^{2} \tan {\left (e + f x \right )}}{f} & \text {for}\: f \neq 0 \\x \left (c + d \tan {\left (e \right )}\right )^{2} \left (A + B \tan {\left (e \right )} + C \tan ^{2}{\left (e \right )}\right ) & \text {otherwise} \end {cases} \]

input
integrate((c+d*tan(f*x+e))**2*(A+B*tan(f*x+e)+C*tan(f*x+e)**2),x)
 
output
Piecewise((A*c**2*x + A*c*d*log(tan(e + f*x)**2 + 1)/f - A*d**2*x + A*d**2 
*tan(e + f*x)/f + B*c**2*log(tan(e + f*x)**2 + 1)/(2*f) - 2*B*c*d*x + 2*B* 
c*d*tan(e + f*x)/f - B*d**2*log(tan(e + f*x)**2 + 1)/(2*f) + B*d**2*tan(e 
+ f*x)**2/(2*f) - C*c**2*x + C*c**2*tan(e + f*x)/f - C*c*d*log(tan(e + f*x 
)**2 + 1)/f + C*c*d*tan(e + f*x)**2/f + C*d**2*x + C*d**2*tan(e + f*x)**3/ 
(3*f) - C*d**2*tan(e + f*x)/f, Ne(f, 0)), (x*(c + d*tan(e))**2*(A + B*tan( 
e) + C*tan(e)**2), True))
 
3.1.60.7 Maxima [A] (verification not implemented)

Time = 0.29 (sec) , antiderivative size = 135, normalized size of antiderivative = 1.03 \[ \int (c+d \tan (e+f x))^2 \left (A+B \tan (e+f x)+C \tan ^2(e+f x)\right ) \, dx=\frac {2 \, C d^{2} \tan \left (f x + e\right )^{3} + 3 \, {\left (2 \, C c d + B d^{2}\right )} \tan \left (f x + e\right )^{2} + 6 \, {\left ({\left (A - C\right )} c^{2} - 2 \, B c d - {\left (A - C\right )} d^{2}\right )} {\left (f x + e\right )} + 3 \, {\left (B c^{2} + 2 \, {\left (A - C\right )} c d - B d^{2}\right )} \log \left (\tan \left (f x + e\right )^{2} + 1\right ) + 6 \, {\left (C c^{2} + 2 \, B c d + {\left (A - C\right )} d^{2}\right )} \tan \left (f x + e\right )}{6 \, f} \]

input
integrate((c+d*tan(f*x+e))^2*(A+B*tan(f*x+e)+C*tan(f*x+e)^2),x, algorithm= 
"maxima")
 
output
1/6*(2*C*d^2*tan(f*x + e)^3 + 3*(2*C*c*d + B*d^2)*tan(f*x + e)^2 + 6*((A - 
 C)*c^2 - 2*B*c*d - (A - C)*d^2)*(f*x + e) + 3*(B*c^2 + 2*(A - C)*c*d - B* 
d^2)*log(tan(f*x + e)^2 + 1) + 6*(C*c^2 + 2*B*c*d + (A - C)*d^2)*tan(f*x + 
 e))/f
 
3.1.60.8 Giac [B] (verification not implemented)

Leaf count of result is larger than twice the leaf count of optimal. 1825 vs. \(2 (127) = 254\).

Time = 1.36 (sec) , antiderivative size = 1825, normalized size of antiderivative = 13.93 \[ \int (c+d \tan (e+f x))^2 \left (A+B \tan (e+f x)+C \tan ^2(e+f x)\right ) \, dx=\text {Too large to display} \]

input
integrate((c+d*tan(f*x+e))^2*(A+B*tan(f*x+e)+C*tan(f*x+e)^2),x, algorithm= 
"giac")
 
output
1/6*(6*A*c^2*f*x*tan(f*x)^3*tan(e)^3 - 6*C*c^2*f*x*tan(f*x)^3*tan(e)^3 - 1 
2*B*c*d*f*x*tan(f*x)^3*tan(e)^3 - 6*A*d^2*f*x*tan(f*x)^3*tan(e)^3 + 6*C*d^ 
2*f*x*tan(f*x)^3*tan(e)^3 - 3*B*c^2*log(4*(tan(f*x)^2*tan(e)^2 - 2*tan(f*x 
)*tan(e) + 1)/(tan(f*x)^2*tan(e)^2 + tan(f*x)^2 + tan(e)^2 + 1))*tan(f*x)^ 
3*tan(e)^3 - 6*A*c*d*log(4*(tan(f*x)^2*tan(e)^2 - 2*tan(f*x)*tan(e) + 1)/( 
tan(f*x)^2*tan(e)^2 + tan(f*x)^2 + tan(e)^2 + 1))*tan(f*x)^3*tan(e)^3 + 6* 
C*c*d*log(4*(tan(f*x)^2*tan(e)^2 - 2*tan(f*x)*tan(e) + 1)/(tan(f*x)^2*tan( 
e)^2 + tan(f*x)^2 + tan(e)^2 + 1))*tan(f*x)^3*tan(e)^3 + 3*B*d^2*log(4*(ta 
n(f*x)^2*tan(e)^2 - 2*tan(f*x)*tan(e) + 1)/(tan(f*x)^2*tan(e)^2 + tan(f*x) 
^2 + tan(e)^2 + 1))*tan(f*x)^3*tan(e)^3 - 18*A*c^2*f*x*tan(f*x)^2*tan(e)^2 
 + 18*C*c^2*f*x*tan(f*x)^2*tan(e)^2 + 36*B*c*d*f*x*tan(f*x)^2*tan(e)^2 + 1 
8*A*d^2*f*x*tan(f*x)^2*tan(e)^2 - 18*C*d^2*f*x*tan(f*x)^2*tan(e)^2 + 6*C*c 
*d*tan(f*x)^3*tan(e)^3 + 3*B*d^2*tan(f*x)^3*tan(e)^3 + 9*B*c^2*log(4*(tan( 
f*x)^2*tan(e)^2 - 2*tan(f*x)*tan(e) + 1)/(tan(f*x)^2*tan(e)^2 + tan(f*x)^2 
 + tan(e)^2 + 1))*tan(f*x)^2*tan(e)^2 + 18*A*c*d*log(4*(tan(f*x)^2*tan(e)^ 
2 - 2*tan(f*x)*tan(e) + 1)/(tan(f*x)^2*tan(e)^2 + tan(f*x)^2 + tan(e)^2 + 
1))*tan(f*x)^2*tan(e)^2 - 18*C*c*d*log(4*(tan(f*x)^2*tan(e)^2 - 2*tan(f*x) 
*tan(e) + 1)/(tan(f*x)^2*tan(e)^2 + tan(f*x)^2 + tan(e)^2 + 1))*tan(f*x)^2 
*tan(e)^2 - 9*B*d^2*log(4*(tan(f*x)^2*tan(e)^2 - 2*tan(f*x)*tan(e) + 1)/(t 
an(f*x)^2*tan(e)^2 + tan(f*x)^2 + tan(e)^2 + 1))*tan(f*x)^2*tan(e)^2 - ...
 
3.1.60.9 Mupad [B] (verification not implemented)

Time = 8.38 (sec) , antiderivative size = 141, normalized size of antiderivative = 1.08 \[ \int (c+d \tan (e+f x))^2 \left (A+B \tan (e+f x)+C \tan ^2(e+f x)\right ) \, dx=\frac {{\mathrm {tan}\left (e+f\,x\right )}^2\,\left (\frac {B\,d^2}{2}+C\,c\,d\right )}{f}-x\,\left (A\,d^2-A\,c^2+C\,c^2-C\,d^2+2\,B\,c\,d\right )+\frac {\mathrm {tan}\left (e+f\,x\right )\,\left (A\,d^2+C\,c^2-C\,d^2+2\,B\,c\,d\right )}{f}+\frac {\ln \left ({\mathrm {tan}\left (e+f\,x\right )}^2+1\right )\,\left (\frac {B\,c^2}{2}-\frac {B\,d^2}{2}+A\,c\,d-C\,c\,d\right )}{f}+\frac {C\,d^2\,{\mathrm {tan}\left (e+f\,x\right )}^3}{3\,f} \]

input
int((c + d*tan(e + f*x))^2*(A + B*tan(e + f*x) + C*tan(e + f*x)^2),x)
 
output
(tan(e + f*x)^2*((B*d^2)/2 + C*c*d))/f - x*(A*d^2 - A*c^2 + C*c^2 - C*d^2 
+ 2*B*c*d) + (tan(e + f*x)*(A*d^2 + C*c^2 - C*d^2 + 2*B*c*d))/f + (log(tan 
(e + f*x)^2 + 1)*((B*c^2)/2 - (B*d^2)/2 + A*c*d - C*c*d))/f + (C*d^2*tan(e 
 + f*x)^3)/(3*f)